home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / A Real Goo236637282001.psc / frmReplace.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  2001-07-23  |  4.5 KB  |  147 lines

  1. VERSION 5.00
  2. Begin VB.Form frmReplace 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Replace"
  5.    ClientHeight    =   1650
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   5415
  9.    Icon            =   "frmReplace.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   1650
  14.    ScaleWidth      =   5415
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   1  'CenterOwner
  17.    Begin VB.CommandButton Command2 
  18.       Caption         =   "&Cancel"
  19.       Height          =   375
  20.       Left            =   3960
  21.       TabIndex        =   0
  22.       Top             =   1200
  23.       Width           =   1335
  24.    End
  25.    Begin VB.CommandButton Command4 
  26.       Caption         =   "Replace &All"
  27.       Height          =   375
  28.       Left            =   3960
  29.       TabIndex        =   8
  30.       Top             =   840
  31.       Width           =   1335
  32.    End
  33.    Begin VB.CommandButton Command3 
  34.       Caption         =   "R&eplace"
  35.       Height          =   375
  36.       Left            =   3960
  37.       TabIndex        =   7
  38.       Top             =   480
  39.       Width           =   1335
  40.    End
  41.    Begin VB.TextBox txtReplaceWith 
  42.       Height          =   285
  43.       Left            =   1200
  44.       TabIndex        =   6
  45.       Top             =   840
  46.       Width           =   2655
  47.    End
  48.    Begin VB.TextBox txtTextToFind 
  49.       Height          =   285
  50.       Left            =   1200
  51.       TabIndex        =   3
  52.       Top             =   120
  53.       Width           =   2655
  54.    End
  55.    Begin VB.CheckBox Check1 
  56.       Caption         =   "&Case sensitive"
  57.       Height          =   255
  58.       Left            =   1200
  59.       TabIndex        =   2
  60.       Top             =   480
  61.       Width           =   1335
  62.    End
  63.    Begin VB.CommandButton Command1 
  64.       Caption         =   "F&ind Next"
  65.       Height          =   375
  66.       Left            =   3960
  67.       TabIndex        =   1
  68.       Top             =   120
  69.       Width           =   1335
  70.    End
  71.    Begin VB.Label Label2 
  72.       AutoSize        =   -1  'True
  73.       Caption         =   "&Replace With:"
  74.       Height          =   195
  75.       Left            =   120
  76.       TabIndex        =   5
  77.       Top             =   840
  78.       Width           =   1020
  79.    End
  80.    Begin VB.Label Label1 
  81.       AutoSize        =   -1  'True
  82.       Caption         =   "&Find what:"
  83.       Height          =   195
  84.       Left            =   120
  85.       TabIndex        =   4
  86.       Top             =   120
  87.       Width           =   735
  88.    End
  89. Attribute VB_Name = "frmReplace"
  90. Attribute VB_GlobalNameSpace = False
  91. Attribute VB_Creatable = False
  92. Attribute VB_PredeclaredId = True
  93. Attribute VB_Exposed = False
  94. Dim LastPos As Variant
  95. Dim LastSearchedText As String
  96. Private Sub Command1_Click()
  97. Dim FoundPos
  98. If Not txtTextToFind.Text = LastSearchedText Then
  99.     LastSearchedText = txtTextToFind.Text
  100.     LastPos = 1
  101. End If
  102. If Check1.Value = 1 Then
  103.     FoundPos = InStr(LastPos, frmMain.txtIni.Text, txtTextToFind.Text)
  104.     FoundPos = InStr(LastPos, frmMain.txtIni.Text, txtTextToFind.Text, vbTextCompare)
  105. End If
  106. If FoundPos = 0 Then
  107.     MsgBox "Sorry, string not found", vbExclamation, Me.Caption
  108.     Exit Sub
  109. End If
  110. LastPos = FoundPos + Len(txtTextToFind.Text) - 1
  111. frmMain.txtIni.SelStart = FoundPos - 1
  112. frmMain.txtIni.SelLength = Len(txtTextToFind.Text)
  113. frmMain.txtIni.SetFocus
  114. End Sub
  115. Private Sub Command2_Click()
  116. Unload Me
  117. End Sub
  118. Private Sub Command3_Click()
  119. frmMain.txtIni.SelText = txtReplaceWith.Text
  120. End Sub
  121. Private Sub Command4_Click()
  122. Dim FoundPos
  123. Dim Counter As Integer
  124. If Not txtTextToFind.Text = LastSearchedText Then
  125.     LastSearchedText = txtTextToFind.Text
  126.     LastPos = 1
  127. End If
  128. Counter = 0
  129. If Check1.Value = 1 Then
  130.     FoundPos = InStr(LastPos, frmMain.txtIni.Text, txtTextToFind.Text)
  131.     FoundPos = InStr(LastPos, frmMain.txtIni.Text, txtTextToFind.Text, vbTextCompare)
  132. End If
  133. If FoundPos = 0 Then Exit Do
  134. LastPos = FoundPos + Len(txtTextToFind.Text) - 1
  135. frmMain.txtIni.SelStart = FoundPos - 1
  136. frmMain.txtIni.SelLength = Len(txtTextToFind.Text)
  137. frmMain.txtIni.SelText = txtReplaceWith.Text
  138. Counter = Counter + 1
  139. Loop Until FoundPos = 0
  140. frmMain.txtIni.SetFocus
  141. MsgBox "Done replacing, " & Counter & " replacements made", vbInformation, Me.Caption
  142. End Sub
  143. Private Sub Form_Load()
  144. SetWindowWord frmReplace.hwnd, SWW_HPARENT, frmMain.hwnd
  145. txtTextToFind.Text = frmMain.txtIni.SelText
  146. End Sub
  147.